<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div class="w1a">
<div class="w2">系統 » 系統權限管理</div>
<form:form modelAttribute="searchForm" id="searchForm" class="form">
	角色名稱：<form:input size="20" id="authName" path="authName" />
	<a href="#do" class="easyui-linkbutton" onclick="doSearch()">查詢</a>
	<a href="#do" class="easyui-linkbutton" onclick="fmClean()">清空</a>
	<%-- <sec:authorize ifAnyGranted="roleAuthEdit"> --%>
	<a href="${appPath}/roleAuth/newForm.htm" class="easyui-linkbutton">新增</a>
	<%-- </sec:authorize> --%>
</form:form>
<table id="tt" class="easyui-datagrid" style="height:360px" url="${appPath}/roleAuth/list.json"  
	singleSelect="true" striped="true" title="權限資料" sortable="true" rownumbers="true" pagination="true">  
	<thead>    
    	<tr>   
            <th field="authName" width="230" sortable="true">角色名稱</th>
            <th field="creationUser" width="100" sortable="true">建檔者</th>  
            <th field="action" width="120" formatter="action">作業</th>  
		</tr>   
	</thead>   
</table> 

</div>
<script>
function action(val,row,ix){ var str = ""; var o = $('#tt').datagrid('getData').rows[ix];
	<sec:authorize ifAnyGranted="admin">
	str = str + "[<a href='${appPath}/roleAuth/get.htm?id="+o.roleSeq+"'>修改</a>]"; 
	str = str + "[<a href='#do' onclick=\"doDel('"+o.roleSeq+"');\">刪除</a>]";
	</sec:authorize>
	return str; 
} 
function doDel(id){
	if (confirm('確定刪除')) {
		$.post('${appPath}/roleAuth/delete.json', {id:id} ,function(data) { if(data){doSearch();}else{alert('刪除失敗');} });
	}
}
function doSearch(){ 
	var object = {};
	$.each($('#searchForm').serializeArray(), function(i, v) { object[v.name] = v.value; });
	$('#tt').datagrid('load', object ); 
} 
function fmClean(){$("#searchForm").form('reset');}
</script>